package com.kaifamiao.exam.date0813;

public class Recursion {

    public long feibo( long n ) {
        if( n < 0 ) {
            throw new RuntimeException("负数是不合理的参数");
        }
        if( n == 0 || n == 1 ) {
            return 1;
        }
        return feibo(n - 2 ) + feibo( n - 1 );
    }

    public static void main(String[] args) {
        Recursion r = new Recursion();

        long n = r.feibo( 0 );
        System.out.println( n );

        n = r.feibo( 1 );
        System.out.println( n );

        n = r.feibo( 2 );
        System.out.println( n );

        n = r.feibo( 3 );
        System.out.println( n );

        n = r.feibo( 4 );
        System.out.println( n );
    }

}
